﻿/**

 * Copyright (c) 2015-2017, FastDev 刘强 (fastdev@163.com).

 *

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *      http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestConsole
{
    public class TestsProxy : TestsBase
    {
        public void RunInstanceAction()
        {
            Console.WriteLine("In TestsProxy.RunInstanceAction!");
        }

        public string RunInstanceFunc()
        {
            Console.WriteLine("In TestsProxy.RunInstanceFunc!");
            return "1";
        }

        public static void RunStaticAction()
        {
            Console.WriteLine("In TestsProxy.RunStaticAction!");
        }

        public static string RunStaticFunc()
        {
            Console.WriteLine("In TestsProxy.RunStaticFunc!");
            return "2";
        }

        public void RunGenInstAction<T>(T input)
        {
            Console.WriteLine("in TestsProxy.RunGenInstAction " + input.ToString());
        }

        public T2 RunGenInstFunc<T1, T2>(T1 t1, int t3)
        {
            Console.WriteLine("in TestsProxy.RunGenInstFunc " + t1.ToString() + "," + t3);
            return default(T2);
        }

        public static void RunGenStatAction<T>(T input)
        {
            Console.WriteLine("in TestsProxy.RunGenStatAction " + input.ToString());
        }

        public static int RunGenStatFunc<T1, T2>(T1 t1, T2 t3)
        {
            Console.WriteLine("in TestsProxy.RunGenStatFunc " + t1.ToString() + "," + t3);
            return 4;
        }


        public static outT RunStaticGeneric<InT, outT>(InT t2)
        {
            Console.WriteLine("in RunMethodToBeProxyed!" + t2.ToString());
            return default(outT);
        }

        public override void Run()
        {
            Safe(() => Console.WriteLine(RunStaticGeneric<TestEntity, string>(new TestEntity { Id = 8 })));
            
            Safe(() => new TestsProxy().RunInstanceAction());
		    Safe(() => Console.WriteLine(new TestsProxy().RunInstanceFunc()));
            Safe(() => new TestsProxy().RunGenInstAction<string>("item1"));
		    Safe(() => Console.WriteLine(new TestsProxy().RunGenInstFunc<string, int>("param1", 2)));
		    Safe(() => TestsProxy.RunStaticAction());
		    Safe(() => Console.WriteLine(TestsProxy.RunStaticFunc()));
		    Safe(() => TestsProxy.RunGenStatAction<string>("param1"));
		    Safe(() => Console.WriteLine(TestsProxy.RunGenStatFunc<string, int>("param1", 2)));
        }

        public override void VirtualTest()
        {
            Console.WriteLine("in TestProxy.VirtualTest!");
            base.VirtualCallBases();
        }

        public override void VirtualCallBases()
        {
            Console.WriteLine("in TestProxy.VirtualCallBase");
        }


        public override void VirtualCallVirtual()
        {
            Console.WriteLine("in TestProxy.VirtualCallVirtuals");
        }
    }
}
